home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16807 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. Path: newsfeed.internetmci.com!miwok!linex1!news
  3. From: mfried@linex.com (Marty Fried)
  4. Subject: Re: word vs. byte alignment option
  5. X-Nntp-Posting-Host: sp91.linex.com
  6. Message-ID: <316dcf45.6005800@news.linex.com>
  7. Sender: news@linex1.linex.com
  8. Organization: Cirrius Cybernetics Corp
  9. X-Newsreader: Forte Agent .99e/32.201
  10. References: <4kdq3b$lhn@sloth.swcp.com>
  11. Date: Fri, 12 Apr 1996 03:40:03 GMT
  12.  
  13. Once upon a time (OK, it was 9 Apr 1996 13:52:43 GMT),
  14. dvines@sparton.com (Dudley Vines) wrote:
  15.  
  16. >Anybody ever have trouble with Borland C++ compiler word vs. byte 
  17. >alignment option?  When I attempt to load a word aligned array into a byte 
  18. >aligned array, the data in the byte aligned array is off by one byte.
  19. >
  20. >The arrays come from separate modules with different alignement options 
  21. >set.
  22. >
  23. >I thought the alignment option only affected speed or memory usage...why 
  24. >doesn't the compiler figure out how to handle the data right?
  25. >
  26. >e-mail help, please...
  27.  
  28. The compiler can only align the data in the way it was told; there's
  29. no way for the compiler to know what another program has used once
  30. it's been compiled.
  31.  
  32. The way this potential problem seems to be more or less handled is by
  33. using pragmas in the include file for alignment of structures declared
  34. in that file, if it doesn't use the default alignment, or even if it
  35. does, just to be safe.  But you have to get fancy, so that you restore
  36. the original alignment.  There's some sort of push/pop mechanism.
  37.  
  38. cc: dvines@sparton.com (Dudley Vines)
  39.  
  40. _______________________________________________________
  41. Marty Fried - mfried@linex.com     Press Enter to Exit
  42. San Anselmo, CA                           -NT message
  43. (MSVC4 + MFC) && (Win95 || NT);             
  44.